<?php

session_start();
if(!isset($_SESSION['uid']))
	die('User not logged in');

$uid = $_SESSION['uid'];
require_once('inc/db_access.inc');
require_once('inc/notes.inc');

$query = $_REQUEST['query'];

$lc = strripos($query,',');
if($lc){
	$ltag = trim(substr($query,$lc+1));

	$ptags = substr($query,0,$lc);
}else {
	$ltag = $query;
}

$dbc = new DBConnection();
$dbc->getNewConnection();

$tags = get_user_tags($dbc, $uid, $ltag);

foreach($tags as $t){
	if($ptags)
		echo "$ptags, ";
	echo "$t\n";
}
?>
